package com.city.java.users.pojo.entity;

import lombok.Data;
import java.time.LocalDateTime;

/**
 * 用户实体类
 */
@Data
public class Users {
    private Long userId;
    private String username;
    private String account;
    private String password;
    private String nickname;
    private Byte age;
    private Integer points;
    private String email;
    private String phone;
    private String address;
    private UserType type;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    private Integer pageNum;
    private Integer pageSize;

    /**
     * 用户类型枚举 - 对应数据库 ENUM('resident', 'admin', 'staff')
     */
    public enum UserType {
        RESIDENT("resident"),
        ADMIN("admin"),
        STAFF("staff");

        private final String value;

        UserType(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public static UserType fromValue(String value) {
            for (UserType type : values()) {
                if (type.value.equalsIgnoreCase(value)) {
                    return type;
                }
            }
            throw new IllegalArgumentException("Invalid user type: " + value);
        }

        @Override
        public String toString() {
            return this.value;
        }
    }
}
